<?php

namespace app\validate;

use think\Validate;

class Sign extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     * typeof => integer,float,bool,string,array,object,null,resouce
     * @var array
     */	
	protected $rule = [
        'timestamp'=>['require','regex'=>'/^[0-9]*$/','typeof'=>'integer','length:10'],
        'sign'=>['require','regex'=>'/^[A-Z0-9]{32}$/','typeof'=>'string','length:32'],
        'apid'=>['require','regex'=>'/^[0-9]*$/'],
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
        'timestamp.require' => '缺少参数1',
        'timestamp.regex' => '参数错误1',
        'sign.require' => '缺少参数2',
        'sign.regex' => '参数错误2',
        'sign.typeof' => '类型错误',
        'apid.require' => '缺少参数3',
        'apid.regex' => '参数错误3',
    ];

    protected $scene = [
        'public'  =>  ['timestamp','sign'],
        'private'  =>  ['timestamp','sign','apid'],
    ];
}
